<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
	<!-- PAGE CONTENT BEGIN -->
	<div class="layui-body" style="background-color:#f2f2f2;">
		<div class="layui-show" >
			<div class="layui-card" style="height:50px;line-height:50px;padding: 0 15px;">
			    <span class="layui-breadcrumb" lay-separator="-">
				  <a href="">首页</a>
				  <a href="">国际新闻</a>
				  <a href="">亚太地区</a>
				  <a><cite>正文</cite></a>
				</span>
			</div>
			<div class="layui-fluid">
				<div class="layui-card">
					<form action="${pageContext.request.contextPath}/student/list" id="selectForm" method="post" class="layui-form layui-card-header" style="padding-top: 15px;height: auto;">
						<!-- 公用部分 -->
						<div class="layui-form-item">
							 <div class="layui-inline">
							 	 <label class="layui-form-label">姓名</label>
								 <div class="layui-input-block" style="width: 100px;">
		     							<input type="text" name="keyword"  placeholder="姓名" autocomplete="off" class="layui-input">
		   						 </div>
						      </div>
						      <div class="layui-inline">
						      	 <div class="layui-input-block" style="width: 100px;">
							      <button class="layui-btn">查询</button>
							     </div>
						      </div>	     
						</div>
					</form>
					<div class="layui-card-body">
					  <table class="layui-table">
					    <colgroup>
					      <col width="150">
					      <col width="150">
					      <col width="200">
					      <col width="150">
					      <col>
					    </colgroup>
					    <thead>
					      <tr>
					        <th>序号</th>
					        <th>姓名</th>
					        <th>学号</th>
					        <th>状态</th>
					        <th>操作</th>
					      </tr> 
					    </thead>
					    <tbody>
					     <c:forEach var="student" items="${pageinfo.resultList}" varStatus="vstatus">
									<tr>
										<td>${(pageinfo.currentPage-1)*pageinfo.paginationSize+vstatus.count}</td>
										<td>${student.name}</td>
										<td>${student.studentNo}</td>
										<td>
											<c:if test="${student.deleted==true}">已删除</c:if>
											<c:if test="${student.deleted==false}">正常</c:if>
										</td>
										<td>
											<a href="javascript:;" onclick="url('${pageContext.request.contextPath}/student/addOrUpdate?id=${student.id}')" class="edit" >编辑</a>
											<a href="javascript:" class="delete user-delete" data-id="${student.id}" >删除</a>
										</td>
									</tr>
								</c:forEach>
					    </tbody>
					  </table>
					  <!-- 分页 -->
					  <div id="pagediv"></div>
					</div>
				</div>
			</div>
		</div>	
	</div>
   <div class="layui-footer">
    <!-- 底部固定区域 -->
    © ssmfo - 底部固定区域
   </div>
	<!-- PAGE CONTENT END -->
<script type="text/javascript">
	var path = '${pageContext.request.contextPath}';
	var totalPageNum = ${pageinfo.totalPageNum};
	var currentPage = ${pageinfo.currentPage};
	var paginationSize = ${pageinfo.paginationSize};
	var totalNum=${pageinfo.totalNum}
	
    layui.use('laypage', function(){
    	  var laypage = layui.laypage;
    	  //执行一个laypage实例
    	  laypage.render({
    	    elem: 'pagediv' //注意，这里的 pagediv 是 ID，不用加 # 号
    	    ,count: totalNum //数据总数，从服务端得到
    	    ,limit: paginationSize//每页显示个数
    	    ,curr:currentPage //当前页
    	    ,jump: function(obj, first){
    	        //首次不执行
    	        if(!first){
    	        	var formEle = $("#selectForm");
       	            var inputEle = $("<input type='hidden' name='reqPage' value='" + obj.curr + "'/>")
       	            formEle.append(inputEle);
       	            formEle.submit();
    	        }
    	    	
    	      }
    	  });
    	});
  
	$(".user-delete").click(function(){
		var id = $(this).attr("data-id");
		if(confirm("确定要删除吗？")){
			location.href = path+"/student/delete?id=" + id;
		}
	});
	
</script>
</body>
</html>